// pages/mine/mine.js
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
const app = getApp()
Page({
  data: {
    userInfo: {},
    motto: 'Hello World',
    avatarUrl: defaultAvatarUrl,
    theme: wx.getSystemInfoSync().theme,
    // orderItems
    orderItems: [
      {
        typeId: 0,
        name: '我的消息',
        url: '../Support/Support',
        imageurl: '../../../images/icons/我的消息.png',
      },
      {
        typeId: 1,
        name: '足迹',
        url: '../Footprint/Footprint',
        imageurl: '../../../images/icons/足迹.png',
      },
      {
        typeId: 2,
        name: '我的收藏',
        url: '../MyCollection/MyCollection',
        imageurl: '../../../images/icons/我的收藏.png'
      },
      {
        typeId: 3,
        name: '我的照片',
        url: '../MyPhotos/MyPhotos',
        imageurl: '../../../images/icons/图库.png'
      }
    ]
  },
  onLoad() {
    wx.onThemeChange((result) => {
      this.setData({
        theme: result.theme
      })
    })
  },
  onChooseAvatar(e) {
    const { avatarUrl } = e.detail 
    this.setData({
      avatarUrl,
    })
  },
  formSubmit(e){
      console.log('昵称：',e.detail.value.nickname)
  },
  getUserInfo: function() {
    wx.getUserInfo({
      success: res => {
        console.log(res.userInfo); // 用户信息
        // 可以将用户信息存储到本地或者发送给服务器进行处理
      },
      fail: err => {
        console.error('获取用户信息失败', err);
      }
    });
  },
  toOrder: function (event) {
    const typeId = event.currentTarget.dataset.typeid;
    let url = '';
    switch (typeId) {
      case 0:
        url = '../Message/Message';
        break;
      case 1:
        url = '../footprint/footprint';
        break;
      case 2:
        url = '../mycollection/mycollection';
        break;
      case 3:
        url = '../myphotos/myphotos';
        break;
      default:
        // 默认处理
        break;
    }
    if (url !== '') {
      wx.navigateTo({
        url: url
      });
    } else {
      // 处理默认情况，或者报错
    }
  },
  
  userinfo:function(){
    wx.navigateTo({
      url: '../login/login',
    })
  },
  to_gotcamera:function(){
    wx.navigateTo({
      url: '../cameraa/cameraa',
    })
  },
  to_gotgetdata:function(){
    wx.navigateTo({
      url: '../Get the data/Get the data',
    })
  },
  to_goUpdata:function(){
    wx.navigateTo({
      url: '../updata/updata',
    })
  },
  // toOrder: function () {     废案跳转，可删（备）——瑞
  //   wx.navigateTo({
  //     url: '../Message/Message',
  //   })
  // },
  to_gotset(){
    wx.navigateTo({
      url: '../set/set',
    })
  },
  to_gotopinion(){
    wx.navigateTo({
      url: '../opinion/opinion',
    })
  },
  to_gotSupport(){
    wx.navigateTo({
      url: '../Support/Support',
    })
  },
  to_gotkeychange(){
    wx.navigateTo({
      url: '../keychange/keychange',
    })
  },
  to_gotcustomer(){
    wx.navigateTo({
      url: '../customer/customer',
    })
  },
  // onLoad: function () {
  //   console.log('onLoad')
  //   var that = this
  //   //调用应用实例的方法获取全局数据
  //   app.getUserInfo(function (userInfo) {
  //     //更新数据
  //     that.setData({
  //       userInfo: userInfo
  //     })
  //   })
  // }
  
})
